using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    public class SSRFANVControl
    {
        #region Local Variable
        private SSRFANVDataAccess _SSRFANVDAO;
        #endregion Local Variable

        #region Method
        public SSRFANVControl()
        {
            _SSRFANVDAO = new SSRFANVDataAccess();
        }

        public SSRFANVInfo Get(
            String SUN_DB,
            String CATEGORY,
            String CODE
        , ref string sErr)
        {
            return _SSRFANVDAO.Get(
            SUN_DB,
            CATEGORY,
            CODE
            , ref sErr);
        }

        public DataTable GetAll(string dtb, ref string sErr)
        {
            return _SSRFANVDAO.GetAll(dtb, ref sErr);
        }
        public DataTable GetCategory_SSRFANV(string SUN_DB, string CATEGORY, ref string sErr)
        {
            return _SSRFANVDAO.GetCategory_SSRFANV(SUN_DB, CATEGORY, ref sErr);
        }

        public Int32 Add(SSRFANVInfo obj, ref string sErr)
        {
            return _SSRFANVDAO.Add(obj, ref sErr);
        }

        public string Update(SSRFANVInfo obj)
        {
            return _SSRFANVDAO.Update(obj);
        }

        public string Delete(
            String SUN_DB,
            String CATEGORY,
            String CODE
        )
        {
            return _SSRFANVDAO.Delete(
            SUN_DB,
            CATEGORY,
            CODE
            );
        }
        public Boolean IsExist(
            String SUN_DB,
            String CATEGORY,
            String CODE
        )
        {
            return _SSRFANVDAO.IsExist(
            SUN_DB,
            CATEGORY,
            CODE
            );
        }

        /*  public string Delete(String arrID)
          {
              string kq = "";
              string[] arrStrID = arrID.Split(',');
              foreach (string strID in arrStrID)
              {
                  if (strID != "")
                  {
                      int ID = Convert.ToInt32(strID);
                      kq += _SSRFANVDAO.Delete(ID);
                  }
              }
              return kq;
          } */

        public DataTableCollection Get_Page(SSRFANVInfo obj, string orderBy, int pageIndex, int pageSize, ref String sErr)
        {
            return _SSRFANVDAO.Get_Page(obj, orderBy, pageIndex, pageSize, ref sErr);
        }

        public DataTable Search(String columnName, String columnValue, String condition, ref String sErr)
        {
            return _SSRFANVDAO.Search(columnName, columnValue, condition, ref  sErr);
        }

        #endregion Method


        public DataTable GetTransferOut(string dtb, string from, string to, ref string sErr)
        {
            return _SSRFANVDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        internal DataTable ToTransferInStruct()
        {
            DTO.SSRFANVInfo info = new SSRFANVInfo();
            return info.ToDataTable();
        }

        public string InsertUpdate(SSRFANVInfo sSRFANVInfo)
        {
            string sErr = "";
            if (IsExist(sSRFANVInfo.SUN_DB, sSRFANVInfo.CATEGORY, sSRFANVInfo.CODE))
            {
                sErr = Update(sSRFANVInfo);
            }
            else Add(sSRFANVInfo, ref sErr);
            return sErr;
        }

        internal string TransferIn(DataRow row)
        {
            throw new NotImplementedException();
        }
    }
}
